package com.hongawen.mybatis.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.hongawen.mybatis.handler.BatchInjector;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2021年12月13日 18:30
 */
@Configuration
public class MybatisConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

    /***
     * 自定义注册器，处理批量插入
     * @author hongawen
     * @date 2023/5/30 14:53
     * @return BatchInjector
     */
    @Bean
    public BatchInjector BatchInjector() {
        return new BatchInjector();
    }


}
